package net.zigin.nhi.could.waste.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil2 {

    private static final Pattern IS_CHINA_PHONE_PATTREN = Pattern.compile("^((13[0-9])|(14(0|[5-7]|9))|(15([0-3]|[5-9]))|(16(2|[5-7]))|(17[0-8])|(18[0-9])|(19([0-3]|[5-9])))\\d{8}$");
    private static final Pattern IS_HK_PHONE_PATTREN = Pattern.compile("^(5|6|8|9)\\d{7}$");

    public static boolean isPhone(String str) {
        return isChinaPhone(str) || isHKPhone(str);
    }

    public static boolean isNullOrEmpty(String content) {
        return content == null || content.length() == 0 || content.trim().length() == 0;
    }

    private static boolean isChinaPhone(String str) {
        if (isNullOrEmpty(str)) {
            return false;
        } else {
            Matcher m = IS_CHINA_PHONE_PATTREN.matcher(str);
            return m.matches();
        }
    }

    private static boolean isHKPhone(String str) {
        if (isNullOrEmpty(str)) {
            return false;
        } else {
            Matcher m = IS_HK_PHONE_PATTREN.matcher(str);
            return m.matches();
        }
    }

    public static void main(String[] args) {
        System.out.println(isPhone("19933443344"));
    }


}
